{include file="public/layout" /}
<body class="laytp-container">
<div class="layui-card" id="search-form">
    <div class="layui-card-body">
    <form class="layui-form" action="">
        <input type="hidden" name="id" value="{$info.id}" />
        <div class="layui-form-item">
            <label class="layui-form-label">支付名称</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="name" lay-verify="required" value="{$info['name']}" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" {if $info['status']== 0}checked{/if} value="0" title="关闭">
                <input type="radio" name="status" {if $info['status']==1}checked{/if} value="1" title="开启">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">LOGO图片：</label>
            <button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="logo" upload-preview="logoPreview" onclick="uploader(this)">上传图片</button>
            <div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：640×640像素</div>
            <div id="logoPreview" class="picsList-class-110">
                <div class="layui-imgbox imgbox-required">
                    <a class="layui-imgbox-close" href="javascript:void(0)" onclick="$(this).parent().find('img').attr('src','').hide();getpicsval('logo','logoPreview');$(this).hide();" title="删除"><i class="layui-icon layui-icon-close-fill-opaque"></i></a>
                    <div class="layui-imgbox-img">
                        <img src="{$info['logo']}"/>
                    </div>
                    <input autocomplete='off' type="hidden" id="logo" name="logo" lay-verify="required" lay-verType="tips" value="{$info['logo']}" style="cursor:default;">
                </div>
            </div>
        </div>
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">LOGO图片</label>-->
<!--            <input type="hidden" name="logo" id="logo" lay-verType="tips" class="layui-input" value="{$info.logo}">-->
<!--            <button style="float:left;" type="button" class="layui-btn layui-btn-primary" onclick="uploader(this)" upload-input="logo" upload-preview="logoPreview">上传图片</button>-->
<!--            <div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：50×50像素</div>-->
<!--            <div id="iconPreview" style="float:left;padding-top:10px;padding-left:110px;clear: both;">-->
<!--                <div class="layui-imgbox"><div class="layui-imgbox-img"><img src="{$info.logo}"/></div></div>-->
<!--            </div>-->
<!--        </div>-->
        {if $type eq 'weixin'}
        {include file="/pay_way/edit_wechat" /}
        {/if}
        {if $type eq 'ali'}
            {include file="/pay_way/edit_ali" /}
        {/if}
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">确认</button>
            </div>
        </div>
    </form>
    </div>
</div>
<script>
    layui.use(function(){
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6,12}$/,
                '密码必须6到12位，且不能出现空格'
            ]
        });
        // 提交事件
        form.on('submit(demo1)', function(data){
            var index = layer.load();
            layer.close(index);

            var field = data.field; // 获取表单字段值
            $.ajax({
                type: "POST",
                url: "{:url('edit')}",
                data: field,
                success: function(res){
                    console.log(res);
                    if(res.status){
                        layer.msg('提交成功');
                    }else{
                        layer.msg(res.msg);
                    }
                    setTimeout(function(){
                        parent.layer.closeAll();
                        parent.tableIns.reload()
                    },1000)
                }
            });
            return false; // 阻止默认 form 跳转
        });

        // 日期
        laydate.render({
            elem: '#date'
        });


    });
    layui.upload.render({
        elem: '.uploadjstxt', //绑定元素
        url: "{:url('Upload/uploadjstxt')}", //上传接口
        accept:'file',
        data:{type:'wx'},
        done: function(res){
            //上传完毕回调
            console.log(res)
            $('input[name="config['+res.field+']"]').val(res.file_path);
            $('#'+res.field+'_text').text('已上传')
            dialog(res.msg,res.status)
        },
        error: function(){
            //请求异常回调
        }
    });
</script>
</body>
</html>